package com.woniuxy.mesboot.service.impl;

import com.woniuxy.mesboot.dto.ProDTO;
import com.woniuxy.mesboot.entity.MesProcess;
import com.woniuxy.mesboot.mapper.MesProcessDetailsMapper;
import com.woniuxy.mesboot.mapper.MesProcessMapper;
import com.woniuxy.mesboot.service.ProcessService;
import com.woniuxy.mesboot.vo.MesProcessVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ProcessServiceImpl implements ProcessService {
    @Resource
    private MesProcessMapper processMapper;
    @Resource
    private MesProcessDetailsMapper mesProcessDetailsMapper;

    @Override
    @Transactional
    public List<MesProcessVO> selectProcedureList() {
        List<MesProcessVO> mesProcessVOS = processMapper.selectProcedureList();
        for (int i = 0; i < mesProcessVOS.size(); i++) {
            Integer id = mesProcessVOS.get(i).getOperationProcedureId();
            mesProcessVOS.get(i).setOperationProcedures(mesProcessDetailsMapper.selectByOperationProcedureId(id));
        }
        return mesProcessVOS;
    }

    @Override
    public List<MesProcess> selectAll() {
        return processMapper.selectAll();
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return processMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(MesProcess record) {
        return processMapper.insert(record);
    }

    @Override
    public int insertSelective(ProDTO record) {
        return processMapper.insertSelective(record);
    }

    @Override
    public MesProcess selectByPrimaryKey(Long id) {
        return processMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(MesProcess record) {
        return processMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(MesProcess record) {
        return processMapper.updateByPrimaryKey(record);
    }
}
